package common.info;

import com.jfinal.plugin.activerecord.Model;

import java.util.Map;

/**
 * Created by Administrator on 2017/5/11.
 */
public class JsonBackInfo {

    Boolean success;
    String message;
    Map data;

    public JsonBackInfo() {
        this.success = false;
        this.message = "未知错误";
    }

    public JsonBackInfo success() {
        setInfo(true, null, null);
        return this;
    }

    public JsonBackInfo success(Map data){
        setInfo(true, null, data);
        return this;
    }

    public JsonBackInfo success(String message){
        setInfo(true, message, null);
        return this;
    }

    public JsonBackInfo success(String message, Map data){
        setInfo(true, message, data);
        return this;
    }

    public JsonBackInfo fail(){
        setInfo(false, null, null);
        return this;
    }

    public JsonBackInfo fail(Map data){
        setInfo(false, null, data);
        return this;
    }

    public JsonBackInfo fail(String message){
        setInfo(false, message, null);
        return this;
    }

    public JsonBackInfo fail(String message, Map data){
        setInfo(false, message, data);
        return this;
    }

    public JsonBackInfo setInfo(boolean state, String message, Map data){
        this.success = state;
        this.message = message;
        this.data = data;
        return this;
    }



    public String getMessage() {
        return message;
    }

    public JsonBackInfo setMessage(String message) {
        this.message = message;
        return this;
    }

    public Map getData() {
        return data;
    }

    public JsonBackInfo setData(Map data) {
        this.data = data;
        return this;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }
}
